package com.itheima.flow;

import javax.swing.*;

public class loop {
    public static void main(String[] args) {
        //1.水仙花数
        flowerNumber();
        //2.复利，本金翻倍
        doubleMoney();
    }

    public static void flowerNumber() {
        int count = 0;
        for (int i = 100; i <= 999; i++) {

            int a = i % 10;//个位 取余
            int b = i / 10 % 10;
            int c = i / 100;
            int d = (int) (Math.pow(a, 3) + Math.pow(b, 3) + Math.pow(c, 3));
            if (d == i) {
                System.out.println(i);
                count++;
            }
        }
        System.out.println("水仙花个数" + count);
    }

    public static void doubleMoney() {
        double principal = 1000000;//本金
        double rate = 0.017;//年利率
        double target = principal * 2;
        int years = 0;

        while (principal < target) {
            principal += principal * rate;
            years++;
        }
        System.out.println(years);


    }
}
